<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
	response.setContentType("text/html;charset=UTF-8");
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
%>
<html lang="zh-cn">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>  
    <link rel="stylesheet" href="<%=path %>/admin/css/pintuer.css">
    <link rel="stylesheet" href="<%=path %>/admin/css/admin.css">
    <script src="<%=path %>/admin/js/jquery.js"></script>
    <script src="<%=path %>/admin/js/pintuer.js"></script>  
		
</head>
<body>
	<form method="post" action="<%=path %>/planManage/deletePlan" id="listform">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 案例列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <!--<li> <a class="button border-main icon-plus-square-o" href="add.html"> 添加内容</a> </li>-->
       <!-- <li>搜索：</li>-->
        <li style='width:60%'>行业
          <select name="s_ishome" id="hangye" class="input tag" onchange="changesearch()" style="width:15%; line-height:17px; display:inline-block">
            <option value="">选择</option>
            <c:forEach items="${hangyeList }" var="list" varStatus="s">
              	<option value="${list.dicCode }">${list.dicName }</option>
              </c:forEach>
          </select>
          &nbsp;&nbsp;
          节日
          <select name="s_isvouch" id="jieri" class="input tag" onchange="changesearch()"  style="width:15%; line-height:17px;display:inline-block">
            <option value="">选择</option>
            <c:forEach items="${jieriList }" var="list" varStatus="s">
              	<option value="${list.dicCode }">${list.dicName }</option>
              </c:forEach>
          </select>
          &nbsp;&nbsp;
          功能
          <select name="s_istop" id="gongneng" class="input tag" onchange="changesearch()"  style="width:15%; line-height:17px;display:inline-block">
            <option value="">选择</option>
            <c:forEach items="${gongnengList }" var="list" varStatus="s">
              	<option value="${list.dicCode }">${list.dicName }</option>
              </c:forEach>
          </select>
          &nbsp;&nbsp;
          状态
          <select name="s_ishome" id="audit" class="input tag audit" onchange="changesearch()" style="width:15%; line-height:17px; display:inline-block">
            <option value="">选择</option>
            <option value="已审核">已审核</option>
            <option value="未审核">未审核</option>
          </select>
        </li>
       
        <li>
          <input type="text" placeholder="请输入搜索关键字" name="keywords" id="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" />
          <a href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()" > 搜索</a></li>
      </ul>
    </div>
    <table class="table table-hover text-center">
    <div id="vos">
      <tr class="thead">
        <th style="text-align:left; padding-left:20px;width:8%">ID</th>
        <!-- <th style="width:8%">排序</th> -->
        <th style="width:20%">案例名称</th>
        <th style="width:15%">标签</th>
        <th style="width:10%">出品</th>
        <th >热度</th>
        <th width="">观看数</th>
        <th width="">上传</th>
        <th width="">状态</th>
        <th width="310">操作</th>
      </tr>
  </div>
       <volist name="list" id="vo"> 
        	        
      	 <c:forEach items="${planList }" var="list" varStatus="s">
              	<tr class="fir">
		          <td id="planId" style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="${list.planId}" />
		           ${list.planId}</td>
		          <td>${list.planName }</td>
		          <td>${list.planTag }</td>
		          <td>${list.planCompnay }</td>
		          <td>
		          	<span class="nums">${list.planHot }</span>
		          	<div class="hp">
          		 		<input name="hot" type="text" />
          		 	<span >保存</span>
          			</div> 
		          </td>
		          <td>
		          	<span class="nums" >${list.planWatch }</span>
		          	<div class="hp">
          		 		<input name="watch" type="text" />
          		 	<span >保存</span>
          			</div>
		          </td>
		          <td >${list.planUpUser }</td>
		          <td <c:if test="${list.planAudit eq '已审核' }">style="color:#009100;"</c:if>>${list.planAudit }</td>		        
		          <td><div class="button-group" style="height:44px;"> 
		          			<c:if test="${list.planAudit eq '未审核' }"><a class="button border-main" onclick="javascript:update(this)"><span class="icon-edit"></span> 修改</a></c:if> 
		          			<a class="button border-main see" <span class="icon-edit"></span>预览</a> 
		          		</div>
		          </td>
		        </tr>
              </c:forEach>
              
        <!-- <tr>
          <td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="" />
           1</td>
          <td><input type="text" name="sort[1]" value="1" style="width:50px; text-align:center; border:1px solid #ddd; padding:7px 0;" /></td>
          <td>这是一套MUI后台精美管理系统</td>
          <td>这是一套MUI后台精美管理系统</td>
          <td><font color="#00CC99"></font></td>
          <td></td>
          <td></td>
          <td><div class="button-group"> <a class="button border-main" href="add.html"><span class="icon-edit"></span> 修改</a> <a class="button border-red" href="javascript:void(0)" onclick="return del(1,1,1)"><span class="icon-trash-o"></span> 删除</a> </div></td>
        </tr> -->
   		 </volist>
      <tr>
        <td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall"/>
          全选 </td>
        <td colspan="10" style="text-align:left;padding-left:20px;"><c:if test="${admin.adRoleNo eq 'HIGH' || admin.adRoleNo eq 'AUDIT' }"><a href="javascript:void(0)" class="button border-green icon-edit" style="padding:5px 15px;margin-right:15px;" onclick="AuditSelect()"> 审核通过</a><a href="javascript:void(0)" class="button border-blue icon-edit" style="padding:5px 15px;margin-right:15px;" onclick="offline()">下线</a></c:if><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a> 
       
      <tr>
        <td colspan="10">
	        <div class="pagelist"> 
	        	 <a id="up" href="javascript:upPage();">上一页</a>
	        	 <c:forEach begin="1" end="${pageSum }" step="1"  var="list" varStatus="s">
	        	 <c:if test="${list eq pageNo }"><span class="current">${list }</span></c:if>
	        	 <c:if test="${list ne pageNo }"><a class="next"  href="javascript:void(0);" onclick="toPage(this);">${list }</a></c:if>
		         <!-- <span class="current">1</span><a  href="">2</a><a href="">3</a> -->
		         </c:forEach>
		         <a href="javascript:nextPage();">下一页</a>
		         <!-- <a href="">尾页</a>  --><a id="sum" href="javascript:void(0);">共${planSum }条</a>
	         </div>
         </td>
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript" src="<%=path%>/admin/js/layer/layer.js" ></script>
<script type="text/javascript">
	var paths = '<%=path %>';
 	var pageNo = $(".current").text();
 	$(".tag").change(function(){
 		changesearch();
 	});
 	$(function(){
 		var dTag = '${deleteTag}';
 		if(dTag >= 1){
 			layer.msg('删除操作成功！');
 		}else if(dTag == -1){
 			layer.msg('系统忙,请稍后重试...');
 		}
 		 if(dTag == -2){
  			layer.msg('删除失败！请先下线该选项...');
  		}
 		var aTag = '${auditTag}';
 		if(aTag >= 1){
 			layer.msg('审核操作成功！');
 		}else if(aTag == -1){
 			layer.msg('系统忙,请稍后重试...');
 		}
 		var offTag = '${offTag}';
 		if(offTag >= 1){
 			layer.msg('下线操作成功！');
 		}else if(offTag == -1){
 			layer.msg('系统忙,请稍后重试...');
 		}
 		var uTag = '${upTag}';
 		if(uTag >= 1){
 			layer.msg('修改操作成功！');
 		}else if(uTag == -1){
 			layer.msg('系统忙,请稍后重试...');
 		}
 	});
 	//标签
 	function tagAdd(){
 		var hang = $("#hangye").val();
		var jie = $("#jieri").val();
		var gong = $("#gongneng").val();
		var tag = '';
		if(hang!=''){
			tag += hang +","
		}
		if(jie!=''){
			tag += jie +","
		}
		if(gong!=''){
			tag += gong +","
		}
		return tag;
 	}
//搜索
function changesearch(){	
		var tag = '';
		tag = tagAdd();
		var audit = $("#audit").val();
		var key = $("#keywords").val();
		newPage(1,key,tag,audit);
		
}
function nextPage(){
	var pageSum = '${pageSum }';
	pageNo = $(".current").text();
	pageNo = parseInt(pageNo);
	if(pageNo<pageSum){
		pageNo+=1;
	}
	var tag = '';
	tag = tagAdd();
	var key = $("#keywords").val();
	var audit = $("#audit").val();
	newPage(pageNo,key,tag,audit);
}
function upPage(){
	pageNo = $(".current").text();
	pageNo = parseInt(pageNo);
	if(pageNo>1){
		pageNo-=1;
	}
	var tag = '';
	tag = tagAdd();
	var key = $("#keywords").val();
	var audit = $("#audit").val();
	newPage(pageNo,key,tag,audit);
}
function toPage(obj){
	var tag = '';
	tag = tagAdd();
	var key = $("#keywords").val();
	pageNo = $(obj).text();
	pageNo = parseInt(pageNo);
	var audit = $("#audit").val();
	newPage(pageNo,key,tag,audit);
}
//newPage or search
function newPage(pageNo,key,tag,audit){
	var params = new Object();
	params.pageNo = pageNo-1;
	params.key = key;
	if(tag ==',,'){
		tag = '';
	}
	params.tag = tag;
	params.audit = audit;
	$.ajax({ 
		type:"post",
		url:"<%=path %>/planManage/newPage",
		data:params,
		dataType: "json",  
        timeout: 100000,  
        cache: false,  
        error: function(){
        	alert("系统忙...");
        },
        success: function(data){
        	var json=eval(data);
        	pageNo = json.pageNo;
        	pageSum = json.pageSum;
        	var htmls = "";
       	 $.each(json.planList, function (index, item) {  
             //循环获取数据   
             var record =new Object(); 
            	 record.id=json.planList[index].planId;
            	 record.name=json.planList[index].planName;
            	 record.tag=json.planList[index].planTag;
            	 record.compnay=json.planList[index].planCompnay;
            	 record.hot=json.planList[index].planHot;
            	 record.watch=json.planList[index].planWatch;
            	 record.audit=json.planList[index].planAudit;
            	 record.user = item.planUpUser;
            	 if(item.planUpUser==null){
            		 record.user ='';
            	 }
            	 
 
               htmls += '<tr class="fir">'
					+'<td id="planId" style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="'+record.id+'" />'+record.id+'</td>'
					+'<td >'+record.name+'</td>'
					+'<td>'+record.tag+'</td>'
					+'<td>'+record.compnay+'</td>'
					+'<td><span class="nums">'+record.hot+'</span><div class="hp"><input name="hot" type="text" /><span >保存</span></div> </td>'
					+'<td><span class="nums" >'+record.watch+'</span><div class="hp"><input name="watch" type="text" /><span >保存</span></div></td>'
					+'<td>'+record.user+'</td>'
					+'<td';
					if(record.audit =='已审核'){
						htmls+=' style="color:#009100;" ';
					}
				htmls+='>'+record.audit+'</td>'
					+'<td><div class="button-group" style="height:44px;"> ';
				if(record.audit =='未审核'){
					htmls+='<a class="button border-main" onclick="javascript:update(this)"><span class="icon-edit"></span> 修改</a>';
				}
				htmls+=' <a class="button border-main see" <span class="icon-edit"></span>预览</a> </div></td>';
				htmls+='</tr>';
         });
        $("#sum").text("共"+json.planSum+"条");
       	 $(".fir").remove();
       	 $(".thead").after(htmls);
       	 //改变页数
       	 $(".next").remove();
       	 $(".current").remove();
       	 var inner = "";
       	 for (var i = 1; i <= pageSum; i++) {
       		 var nowPage = "";
			if(i == pageNo+1){
				nowPage = '<span class="current">'+i+'</span>';
			}else{
				nowPage = '<a class="next"  href="javascript:void(0);" onclick="toPage(this);">'+i+'</a>';
			}
			inner +=nowPage;
		}
       	 $("#up").after(inner);
        }   
	});
}

//预览

$(document).on("click",".see",function(){
	
	 seeHtml= '<div class="ks">';
	var id = $(this).closest(".fir").find("#planId").text().trim();
	$.ajax({ 
		type:"post",
		url:"<%=path %>/planManage/see",
		data:{planId:id},
		dataType:"json",
        timeout: 50000,  
        cache: false,  
        error: function(){
        	alert("系统忙...");
        },
        success: function(data){
        	var json=eval(data);
        	var planDescription = json.planDescription;
        	planDescription = planDescription.substring(0,100);
			seeHtml +='<div class="tc-iphone"><div class="kuang">'
					+'<iframe src="'+json.planUrl+'" frameborder="0" width="390" height="620" scrolling="yes"></iframe></div></div><div class="zs-list tc-list">'
					+'<p id="name">'+json.planName+'</p>'
					+'<span class="fa fa-eye sc float-left"></span>'
					+'<span class="float-left tc-ll" id="watch">'+json.planWatch+'</span><span class="fa fa-heart float-left sc"></span><span class="float-left" id="hot">'+json.planHot+'</span><span class="float-left" id="company" style="margin-left:50px;">出品：'+json.planCompnay+'</span>'
					+'<span title="'+json.planDescription+'" class="tc-st" style="margin:10px 0px;" id="description">'+planDescription+'</span>'
					/* +'<span class="tc-cp" id="company">出品：'+json.planCompnay+'</span>' */
					+'<span class="fa fa-tag sc float-left"></span>'
					+'<span class="float-left zs-ll" id="tag">'+json.planTag+'</span>'
					+'<span class="tc-ewm"><img id = "imgSrc" src="http://pan.baidu.com/share/qrcode?w=150&h=150&url='+json.planUrl+'" alt="" />'
					+'<p class="tc-sys">扫一扫手机预览</p></span>'
					+'</div><div class="zs-lb"><div class="btn-left"><img src="'+paths+'/front/img/left.jpg" alt="" /></div><div class="only-out"><ul class="only only-scroll" id="pics">';
			var pics = json.planPics;
			var pic = pics.split(',');
		 	for (var i = 0; i < 8; i++) {
		 		if(pic[i]&&pic[i] != ''){
				seeHtml+='<a href="#"><li><img src="'
						+paths+"/file/getImg.html?saveAddress="+pic[i]
						+'" alt="" /></li></a>';
		 		}
			}	 	
			seeHtml+='</ul></div><div class="btn-right"><img src="'+paths+'/front/img/right.jpg" alt="" /></div></div></div>';
			
			var script1="<script>"+
			"var scrollWidth=300*$('.only-scroll li').length-12;"+
			"var leftWidth=scrollWidth-888;"+
			"$('.only-scroll').width(scrollWidth);"+
			"$('.btn-right').hover(function(){"+
			"	var nowLeft=parseInt($('.only-scroll').css('marginLeft'));"+
			"	var lastWidth=leftWidth+nowLeft;"+
			"	var timerLeft=lastWidth*10;"+
			"	$('.only-scroll').animate({marginLeft:-leftWidth},timerLeft,'linear');"+
			"	},function(){"+
			"	$('.only-scroll').stop();"+
			"});"+
			"$('.btn-left').hover(function(){"+
			"	var nowLeft=parseInt($('.only-scroll').css('marginLeft'));"+
			"	var timerRight=-nowLeft*10;"+
			"	$('.only-scroll').animate({marginLeft:0},timerRight,'linear');"+
			"	},function(){"+
			"	$('.only-scroll').stop();"+
			"});"+"$('.only-scroll').css({marginLeft:0});<\/script>";
			window.parent.op(seeHtml+script1);

        }
       });
});

//修改
function update(obj){
	var id = $(obj).closest(".fir").find("#planId").text().trim();
	<%-- $.ajax({ 
		type:"post",
		url:"<%=path %>/planManage/toUpdate",
		data:{planId:id},  
        timeout: 100000,  
        cache: false,  
        error: function(){
        	alert("系统忙...");
        },
        success: function(data){	
        	window.location.href="<%=path %>/planManage/update";
        }
       }); --%>
       window.location.href="<%=path %>/planManage/toUpdate?planId="+id;
}
//单个删除
function del(id,mid,iscid){
	if(confirm("您确定要删除吗?")){
		
	}
}

//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})

//批量删除
function DelSelect(){
	$("#listform").attr("action",paths+"/planManage/delete");
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}

//批量审核
function AuditSelect(){
	$("#listform").attr("action",paths+"/planManage/approve");
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认审核通过选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您审核通过的内容!");
		return false;
	}
}

//批量下线
function offline(){
	$("#listform").attr("action",paths+"/planManage/offline");
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认下线选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您下线的内容!");
		return false;
	}
}

//批量排序
function sorts(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		
		$("#listform").submit();		
	}
	else{
		alert("请选择要操作的内容!");
		return false;
	}
}


//批量首页显示
function changeishome(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}

//批量推荐
function changeisvouch(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");	
		
		return false;
	}
}

//批量置顶
function changeistop(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}


//批量移动
function changecate(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		
		$("#listform").submit();		
	}
	else{
		alert("请选择要操作的内容!");
		
		return false;
	}
}

//批量复制
function changecopy(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		var i = 0;
	    $("input[name='id[]']").each(function(){
	  		if (this.checked==true) {
				i++;
			}		
	    });
		if(i>1){ 
	    	alert("只能选择一条信息!");
			$(o).find("option:first").prop("selected","selected");
		}else{
		
			$("#listform").submit();		
		}	
	}
	else{
		alert("请选择要复制的内容!");
		$(o).find("option:first").prop("selected","selected");
		return false;
	}
}

	$(document).on("click",".table tr td>span",function(){
			var text=$(this).text();
			$(this).siblings().show();
			$(this).siblings().children('input').focus();
			$(this).siblings().children('input').val(text);
			$(".table tr td>span").not($(this)).parent().find(".hp").hide();
		});


		$(document).on("click",".hp span",function(){
			var id = $(this).closest(".fir").find("#planId").text().trim();
			var tagName = $(this).closest(".hp").find("input").attr("name");
			var hot = $(this).closest(".hp").find("input").val();
				hot = parseInt(hot);
			var $this = $(this);
			$.ajax({ 
				type:"post",
				url:"<%=path %>/planManage/updateHotOrWatch",
				data:{planId:id,tagName:tagName,num:hot},  
				dataType:"json",
		        timeout: 100000,  
		        cache: false,  
		        error: function(){
		        	alert("系统忙...");
		        },
		        success: function(data){	
		        	var s = parseInt(data);
		        	if(s>=1){
		        		$this.closest("td").find(".nums").text(hot);
		        		layer.msg("修改成功");
		        		
		        		
		        	}else if(s==-1){
		        		layer.msg("系统忙...");
		        	}
		        }
		       });
			$(this).parent().hide();
		});

	function targo(){
	history.go(0);
}
	  $(document).on("click","*:not(.nums)",function(event){
		  if(event.target==this){
			  $(".hp").hide();
		  }
		
	});  
	/*   $('.hp input').each(function(){
		 $(document).on("blur",".hp input",function(){
			$(this).parent().hide();
		});
	})   */


</script>
</body>
 <script type="text/javascript" src="<%=path%>/admin/js/layer/layer.js" ></script>
<script type="text/javascript">

</script>
</html>